<?php
namespace App\Controller\Common;

use App\Base\BaseController;
use App\BaseExt\PicUpload;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;


class VueUploadController extends BaseController
{

    /**
     * @Route("/MyVuePicUpload" , name="MyVuePicUpload")
     */
    public function MyWebPicUpload(Request $request)
    {
        if (!$name = $this->getParamRequired("name")) {
            $name = "Filedata";
        }
        $picUploadModel = new PicUpload();
        $rst = $picUploadModel->doUpload($name);
        $data = $picUploadModel->getData();
        if ($data) {
            $re = array(
                "errno"=>0,
                "data"=>["http://".$request->getHttpHost().$data[$name]],
            );
        } else {
            $re = $rst;
        }
        return new JsonResponse($re);
    }
}
